package com.xm9m.web.service.security;


import com.salesmanager.web.utils.ServletUtils;
import com.xm9m.web.service.api.response.common.SimpleResponse;
import com.xm9m.web.service.constants.ResultMessage;
import com.xm9m.web.service.constants.StatusCode;
import com.xm9m.web.service.internal.util.BuildResponseUtil;
import org.springframework.security.access.AccessDeniedException;
import org.springframework.security.web.access.AccessDeniedHandler;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * Created by 123 on 2015/12/14.
 */
public class CustomerDeniedHandler implements AccessDeniedHandler {

    @Override
    public void handle(HttpServletRequest request,
                       HttpServletResponse response,
                       AccessDeniedException accessDeniedException) throws IOException,
            ServletException {
        ServletUtils.responseOutWithJson(response, BuildResponseUtil.buildSimpleResponse(StatusCode.LOGIN_ERROR));

    }

    public String getAccessDeniedUrl() {
        return accessDeniedUrl;
    }

    public void setAccessDeniedUrl(String accessDeniedUrl) {
        this.accessDeniedUrl = accessDeniedUrl;
    }

    private String accessDeniedUrl = null;

}


